package com.yj.IteratorAndCompositePattern;
import java.util.Iterator;

public class Waitress1 {
	MenuComponent allMenus;
	
	public Waitress1(MenuComponent allMenus){
		this.allMenus=allMenus;
	}
	
	public void printMenu(){
		allMenus.print();
	}
	
	public void printVegetarianMenu(){
		Iterator iterator=(Iterator) allMenus.createIterator();
		System.out.println("\nVEGETARIAN MENU\n----");
		while(iterator.hasNext()){
			MenuComponent menuComponent=(MenuComponent) iterator.next();
			try{
				if(menuComponent.isVegetarian()){
					menuComponent.print();
				}
			}catch(UnsupportedOperationException e){}
		}
	}
}
